<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <base th:href="@{/}">
  <meta charset="UTF-8">
  <title>医生对应的患者挂号列表</title>
  <link rel="stylesheet" href="css/bootstrap.min.css" />
  <script src="js/jquery.min.js"></script>
  <link rel="stylesheet" href="css/mainstyle.css" />
  <script src="/js/bootstrap.bundle.min.js"></script>
</head>
<body>
<div th:insert="~{doctor/header}"></div>
<main id="main">
  <!--副标题-->
  <section class="breadcrumbs">
    <div class="container">
      <div class="d-flex justify-content-between align-items-center">
        <h2>我的挂号</h2>
        <ol>
          <li><a href="#">首页</a></li>
          <li><a href="#">我的挂号</a></li>
        </ol>
      </div>
    </div>
  </section>
  <section class="inner-page">
    <div class="container">
      <div class="card">
        <div class="card-header">
          <h3 class="card-title">患者挂号列表</h3>
        </div>
        <div class="card-body">
          <form th:action="@{/doctor/searchByDetailAndYyrq}" method="get" class="formstlye col-7">
            <label for="detail">选择挂号星期：</label>
            <select id="detail" name="detail">
              <option value="Monday">星期一</option>
              <option value="Tuesday">星期二</option>
              <option value="Wednesday">星期三</option>
              <option value="Thursday">星期四</option>
              <option value="Friday">星期五</option>
              <option value="Saturday">星期六</option>
              <option value="Sunday">星期日</option>
            </select>
            <label for="yyrq">选择时间段：</label>
            <select id="yyrq" name="yyrq">
              <option value="上午">上午</option>
              <option value="下午">下午</option>
            </select>
            <button type="submit" style=" border-radius: 8px; ">搜索</button>
          </form>
          <div class="table-responsive">
            <table class="table text-center">
              <tbody class="text-center">
              <tr>
                <th>序号</th>
                <th>挂号患者名称</th>
                <th>挂号时间</th>
                <th>具体时间</th>
                <th>状态</th>
                <th>操作</th>
              </tr>
              <tr th:each="mzgh ,stat:${mzghs}">
                <td th:text="${stat.count}"></td>
                <td th:text="${mzgh.uname}"></td>
                <td id="detailCell" th:text="${mzgh['detail']}"></td>
                <td th:text="${mzgh.yyrq}"></td>
                <td>
                  <span th:text="${mzgh.status == '0' ? '未叫号' : (mzgh.status == '1' ? '已叫号' : '未知状态')}"></span>
                </td>
                <td>
                  <form th:if="${mzgh.status == '0'}" th:action="@{/doctor/call(id=${mzgh.id})}" method="post" style="display:inline">
                    <button type="submit" class=" btn btn1 btn-sm" style="color:#409eff;background: #ecf5ff;border: 1px solid #b3d8ff;">叫号</button>
                  </form>
                  <form th:if="${mzgh.status == '1'}" th:action="@{/doctor/cancelCall(id=${mzgh.id})}" method="post" style="display:inline">
                    <button type="submit" class="btn btn2 btn-sm" style="color: #eec4a0;background: #fdf6ec;border: 1px solid #f8e6cb;">取消叫号</button>
                  </form>
                  <form th:if="${mzgh.status == '1'and !existingRecordMzghIds.contains(mzgh.id)}" th:action="@{/doctor/showAddARecord}" method="post" style="display:inline">
                    <input type="hidden" name="mId" th:value="${mzgh.id}"/>
                    <button type="submit" class="btn btn-sm" style="color: #0accce;background: #e5fcfb;border-color: #ace2dd;">添加就诊记录</button>
                  </form>
                </td>
              </tr>
              <tr>
                <td colspan="6" style="border: none;">
                  <ul class="pagination justify-content-center">
                    <li class="page-item" th:if="${currentPage} != 1">
                      <a class="page-link"
                         th:href="@{/doctor/selectMzgh(currentPage=${currentPage - 1})}">上一页</a>
                    </li>
                    <li class="page-item disabled">
                      <a class="page-link" href="#">第<span
                              th:text="${currentPage}"></span>页</a>
                    </li>
                    <li class="page-item disabled">
                      <a class="page-link" href="#">共<span
                              th:text="${totalPage}"></span>页</a>
                    </li>
                    <li class="page-item" th:if="${currentPage} !=${totalPage}">
                      <a class="page-link"
                         th:href="@{/doctor/selectMzgh(currentPage=${currentPage + 1})}">下一页</a>
                    </li>
                  </ul>
                </td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
    </div>
  </section>
</main>
<script>
  // 英文到中文的映射
  const translationMap = {
    'Monday': '星期一',
    'Tuesday': '星期二',
    'Wednesday': '星期三',
    'Thursday': '星期四',
    'Friday': '星期五',
    'Saturday': '星期六',
    'Sunday': '星期日'
    // 添加其他需要翻译的英文到中文的映射
  };

  // 页面加载完成后执行
  document.addEventListener('DOMContentLoaded', function() {
    // 选择所有包含挂号详情的单元格
    var detailCells = document.querySelectorAll('#detailCell');
    detailCells.forEach(function(cell) {
      // 获取单元格中的文本
      var detailText = cell.textContent || cell.innerText;
      // 替换文本为中文
      cell.textContent = translationMap[detailText] || detailText;
    });
  });

</script>
</body>
</html>
